<?php 
// DETERMINE IF THE EMAIL MATCHES

if ($email_attempt && $id) {
	include('../dbconnect.php'); 	
	$sql = "SELECT * FROM local WHERE id=$id";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    
	$email = $myrow["email"];

	if ($email == $email_attempt) {
		Header("Location: http://www.kootenayrideshare.com/rideshare/addride_local.php?id=$id");
	} else {
		echo "<html>";
		include("../header.php") ;
		echo "<center><p><b>The email address is incorrect. <br><br>Click on the back button and try again.</b></p></center>";
	}

} else {

// GENERATE HTML  
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Rideshare</title>
<link rel="stylesheet" type="text/css" href="../external.css">
</head>

<?php 
include("../header.php") ;
?>

	<h1 align="center">Edit a Journey</h1>
	<p><form method="post" name="email_attempt_form" action="<?php echo $PHP_SELF ?>">
	<input type="hidden" name="id" value="<?php echo $id ?>">
		
    <table align="center" border="0" cellpadding="1" cellspacing="0" width="600" bgcolor="#666633">
      <tr>	
      	<td> 
      	   
      <table align="center" border="0" cellpadding="6" cellspacing="1" width="600" bgcolor="#CCCC99">
      <tr>	
        <td><b>Email:</b><br>
        Your email address will remain private, we will not give it to anyone.</td>
        <td><input type="text" name="email_attempt" value="" size="40"></td>
      </tr>		
      <tr>	
        <td align="center" colspan="2"><input type="submit" value="submit" name="submit"></td>
      </tr>
    </table>
    </td>
      </tr>
    </table>
</form>
</p>
		
<?php
} 
 include("../footer.php"); 
?>
</html>
